<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1,maxinum-scale=1">
    <title> 我的IM</title>
    <link rel="stylesheet" href="/static/mui/css/mui.min.css">
    <script src="/static/js/axios.min.js"></script>
    <script src="/static/js/vue.min.js"></script>
    <script src="/static/mui/js/mui.js"></script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
    <h1 class="mui-title">登陆</h1>
</header>
<div class="mui-content" id="pageapp">
    <form id="login-form" class="mui-input-group">
        <div class="mui-input-row">
            <label>账户</label>
            <input v-model="user.name" placeholder="请输入用户名" type="text" class="mui-input-clear">
        </div>
        <div class="mui-input-row">
            <label>账户</label>
            <input v-model="user.password" placeholder="请输入密码" type="password" class="mui-input-clear">
        </div>
    </form>
    <div class="mui-content-padded">
        <button @click="login" type="button" class="mui-btn mui-btn-block mui-btn-primary">登陆</button>
        <div class="link-area"><a id="reg" href="register">注册</a> <span class="spliter">|</span></div>
    </div>

</div>
</body>
</html>
<script>
    var app = new Vue({
        el:"#pageapp"
        ,data:function (){
            return {
                user:{
                    name:"",
                    password:"",
                }
            }
        },
        methods:{
           login:function (){
               //监测手机号是否正确
               console.log("login")
               //检测密码是否为空

               //网络请求
               //封装了promis
               axios.post("user/findUserByNamePwd").then(res=>{
                   console.log(res)
                   if (res.code!=0){
                       mui.toast(res.message)
                   }else{
                       location.replace("//127.0.0.1/chat/main.html")
                       mui.toast("登陆成功，即将跳转")
                   }
               })
           }
        },
    })
</script>